import { Controller } from "../../mvc/core/Controller";
import { DataEvent } from "../events/DataEvent";
import { MsgManager } from "../manager/MsgManager";
import { Language } from "../../../extend/language/Language";
import { EGuildPosition } from "../../../Message/Game/EGuildPosition";
import { CrossGuildWarChooseForTopData } from "../view/crossGuildWar/data/CrossGuildWarChooseForTopData";
import { Alert } from "../../../com/mui/controls/Alert";
import { GameProxy } from "../mvc/GameProxy";
import { CrossGuildWarModuleShowControlCenter } from "../view/crossGuildWar/control/CrossGuildWarModuleShowControlCenter";
import { CallLater } from "../../common/net/CallLater";
import { CrossGuildWarStage } from "../view/crossGuildWar/data/CrossGuildWarStage";
import { CrossGuildWarEnterWaittingRoomTips } from "../view/crossGuildWar/control/CrossGuildWarEnterWaittingRoomTips";
import { CrossGuildWarUtil } from "../view/crossGuildWar/util/CrossGuildWarUtil";
import { CrossGuildWarModuleTabIndex } from "../view/crossGuildWar/data/CrossGuildWarModuleTabIndex";
import { Dispatcher } from "../../mvc/core/Dispatcher";
import { EventName } from "../mvc/EventName";
import { NetDispatcher } from "../../mvc/core/NetDispatcher";
import { EPublicCommand } from "../../../Message/Command/EPublicCommand";
import { EEntityFightMode } from "../../../Message/Public/EEntityFightMode";
import { GameMapUtil } from "../scene/map/GameMapUtil";
import { DisplayUtil } from "../../common/DisplayUtil";
import { CrossGuildWarCopyInfoPanel } from "../view/crossGuildWar/CrossGuildWarCopyInfoPanel";
import { MessageBlock } from "../../../Framework/MQ/MessageBlock";
import { SGuildWarSingUpTime } from "../../../Message/Public/SGuildWarSingUpTime";
import { CrossGuildWarBtn } from "../view/crossGuildWar/CrossGuildWarBtn";
import { SGuildWarSingUpInfo } from "../../../Message/Public/SGuildWarSingUpInfo";
import { GuildwarSignListWindow } from "../view/guildWar/GuildwarSignListWindow";
import { SGuildWarOpen } from "../../../Message/Public/SGuildWarOpen";
import { SCrossGuildWarChooseGroupInfo } from "../../../Message/Public/SCrossGuildWarChooseGroupInfo";
import { CrossGuildWarChooseForTopBtnData } from "../view/crossGuildWar/data/CrossGuildWarChooseForTopBtnData";
import { LoaderHelp } from "../../common/display/LoaderHelp";
import { ResFileConst } from "../resource/ResFileConst";
import { SCrossGuildWarChooseEnemyInfo } from "../../../Message/Public/SCrossGuildWarChooseEnemyInfo";
import { SCrossGuildWarBeginWar } from "../../../Message/Public/SCrossGuildWarBeginWar";
import { ECrossGuildWarFightStatus } from "../../../Message/Public/ECrossGuildWarFightStatus";
import { SCrossGuildWarEndWar } from "../../../Message/Public/SCrossGuildWarEndWar";
import { SCrossGuildWarMatchInfos } from "../../../Message/Public/SCrossGuildWarMatchInfos";
import { SCrossGuildWarFinalRanks } from "../../../Message/Public/SCrossGuildWarFinalRanks";
import { DataProvider } from "../../../fl/data/DataProvider";
import { SCrossGuildWarLeftNum } from "../../../Message/Public/SCrossGuildWarLeftNum";
import { SCrossGuildWarScore } from "../../../Message/Public/SCrossGuildWarScore";
import { SCrossGuildWarMatchInfo } from "../../../Message/Public/SCrossGuildWarMatchInfo";
import { CrossGuildWarModule } from "../view/crossGuildWar/CrossGuildWarModule";
import { CrossGuildWarSignUpWin } from "../view/crossGuildWar/CrossGuildWarSignUpWin";
import { CrossGuildWarChooseGroupWin } from "../view/crossGuildWar/CrossGuildWarChooseGroupWin";
import { SCrossGuildWarChooseGroup } from "../../../Message/Public/SCrossGuildWarChooseGroup";
type int = number;
//class CrossGuildWarController
    
    export  class CrossGuildWarController extends Controller
    {
        constructor()
        {
            super();this.canNotUseItemData = {"category": 3, "effect": 1, "types":"#0#1#11#13#14#15#"};
            
            return;
        }

        /* internal  */chooseForTopXReqHandler(arg1: DataEvent): void
        {
            var loc3=null;
            if (cache.guild.myGuildInfo == null) 
            {
                MsgManager.showRollTipsMsg(Language.getString(41802));
                return;
            }
            if (!(cache.guild.myGuildInfo.position == EGuildPosition._EGuildLeader) && !(cache.guild.myGuildInfo.position == EGuildPosition._EGuildDeputyLeader)) 
            {
                MsgManager.showRollTipsMsg(Language.getString(80562));
                return;
            }
            var loc1=cache.crossGuildWar.getOurGuildChooseEnemyData();
            if (loc1 != null) 
            {
                if ((loc3 = loc1.guildName) == null || loc3 == "") 
                {
                    loc3 = Language.getString(80565);
                }
                MsgManager.showRollTipsMsg(Language.getStringByParam(80568, loc3));
                return;
            }
            var loc2=arg1.data as CrossGuildWarChooseForTopData;
            if (loc2 == null) 
            {
                return;
            }
            if (loc2.guildName == cache.guild.myGuildInfo.guildName && cache.guild.myGuildInfo.guildId == loc2.guildId.id) 
            {
                return;
            }
            this._chooseForTopXData = loc2;
            Alert.show(Language.getStringByParam(80570, loc2.guildName), null, Alert.OK | Alert.CANCEL, null, this.closeChooseForTopXConfirm);
            return;
        }

        /* internal  */closeChooseForTopXConfirm(arg1: int): void
        {
            if (!(arg1 == Alert.OK) || this._chooseForTopXData == null) 
            {
                return;
            }
            GameProxy.copy.crossGuildWarChooseEnemy(this._chooseForTopXData.guildId, this._chooseForTopXData.myIndex);
            return;
        }

        /* internal  */moduleTabChangedHandler(arg1: DataEvent): void
        {
            if (this._module == null) 
            {
                return;
            }
            if (this._moduleViewControlCenter == null) 
            {
                this._moduleViewControlCenter = new CrossGuildWarModuleShowControlCenter(this._module);
            }
            this._moduleViewControlCenter.moduleTabChangedHandler();
            return;
        }

        /* internal  */stageChangedHandler(arg1: DataEvent): void
        {
            CallLater.addCallBack(this.stageChangedTimeOut);
            if (cache.crossGuildWar.curStage == CrossGuildWarStage.SignUp) 
            {
                if (this._enterTipsControl == null) 
                {
                    this._enterTipsControl = new CrossGuildWarEnterWaittingRoomTips();
                }
                if (!this._enterTipsControl.isWorking) 
                {
                    this._enterTipsControl.startWork(cache.crossGuildWar.getSignUpLeftSeconds());
                }
            }
            return;
        }

        /* internal  */stageChangedTimeOut(): void
        {
            if (this._module == null) 
            {
                return;
            }
            if (this._moduleViewControlCenter == null) 
            {
                this._moduleViewControlCenter = new CrossGuildWarModuleShowControlCenter(this._module);
            }
            var loc1=CrossGuildWarUtil.getCurRoundIndex(cache.crossGuildWar.lastStage);
            var loc2=CrossGuildWarUtil.getCurRoundIndex(cache.crossGuildWar.curStage);
            if (!(loc1 == loc2) && loc1 >= 0 && loc2 >= 0) 
            {
                if (this._module) 
                {
                    this._curViewingRoundIndex = loc2;
                    this._isViewingHistory = false;
                    this._module.updateTopBtns(cache.crossGuildWar.getChooseForTopBtnDatas(loc2));
                    this._module.setTabSelected(CrossGuildWarModuleTabIndex.chooseEnemy);
                    this._module.showChooseForTopWin();
                }
            }
            return;
        }

        /* internal  */signUpSuccessHandler(arg1: DataEvent): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.GuildWarIsNotice, true));
            if (this._signUpWin != null) 
            {
                this._signUpWin.signUpEnabled = false;
            }
            return;
        }

        /* internal  */crossGuildWarNoticeReqHandler(arg1: DataEvent): void
        {
            var loc1=Boolean(arg1.data);
            GameProxy.copy.setCrossGuildWarNotice(loc1);
            return;
        }

        protected /* override */ initServer(): void
        {
            NetDispatcher.addCmdListener(EPublicCommand._ECmdPublicCrossGuildWarSignUpTime, this.signUpStartHandler);
            NetDispatcher.addCmdListener(EPublicCommand._ECmdPublicCrossGuildWarSignUpInfo, this.signUpInfoHandler);
            NetDispatcher.addCmdListener(EPublicCommand._ECmdPublicCrossGuildWarOpen, this.openHandler);
            NetDispatcher.addCmdListener(EPublicCommand._ECmdPublicCrossGuildWarClose, this.closeHandler);
            NetDispatcher.addCmdListener(EPublicCommand._ECmdPublicCrossGuildWarChooseGroupTime, this.chooseGroupTimeHandler);
            NetDispatcher.addCmdListener(EPublicCommand._ECmdPublicCrossGuildWarChooseGroupInfo, this.chooseGroupHandler);
            NetDispatcher.addCmdListener(EPublicCommand._ECmdPublicCrossGuildWarChooseEnemyTime, this.chooseEnemyTimeHandler);
            NetDispatcher.addCmdListener(EPublicCommand._ECmdPublicCrossGuildWarChooseEnemyInfo, this.chooseEnemyHandler);
            NetDispatcher.addCmdListener(EPublicCommand._ECmdPublicCrossGuildWarBeginWar, this.roundBeginHandler);
            NetDispatcher.addCmdListener(EPublicCommand._ECmdPublicCrossGuildWarEndWar, this.roundEndHandler);
            NetDispatcher.addCmdListener(EPublicCommand._ECmdPublicCrossGuildWarMatchInfo, this.liveInfoHandler);
            NetDispatcher.addCmdListener(EPublicCommand._ECmdPublicCrossGuildWarFinalRank, this.rankInfoHandler);
            NetDispatcher.addCmdListener(EPublicCommand._ECmdPublicCrossGuildWarLeftNum, this.leftPlayerInfoHandler);
            NetDispatcher.addCmdListener(EPublicCommand._ECmdPublicCrossGuildWarScore, this.copyInfoUpdateHandler);
            NetDispatcher.addCmdListener(EPublicCommand._ECmdPublicCrossGuildWarGroupEnd, this.groupEndHandler);
            Dispatcher.addEventListener(EventName.CrossGuildWarShowModuleReq, this.openModuleReqHandler);
            Dispatcher.addEventListener(EventName.CrossGuildWarSignUpReq, this.signUpReqHandler);
            Dispatcher.addEventListener(EventName.CrossGuildWarPassToReq, this.enterCopyReqHandler);
            Dispatcher.addEventListener(EventName.CrossGuildWarShowSignUpList, this.showSignUpListHandler);
            Dispatcher.addEventListener(EventName.CrossGuildWarChooseGroupReq, this.chooseGroupReqHandler);
            Dispatcher.addEventListener(EventName.CrossGuildWarSelectForTopXReq, this.chooseForTopXReqHandler);
            Dispatcher.addEventListener(EventName.CrossGuildWarModuleTabChange, this.moduleTabChangedHandler);
            Dispatcher.addEventListener(EventName.CrossGuildWarStageChanged, this.stageChangedHandler);
            Dispatcher.addEventListener(EventName.CrossGuildWarSignUpSuccessMsg, this.signUpSuccessHandler);
            Dispatcher.addEventListener(EventName.CrossGuildWarIsNotice, this.crossGuildWarNoticeReqHandler);
            Dispatcher.addEventListener(EventName.CrossGuildWarLeaveReq, this.leaveWarToWaittingRoomReqHandler);
            Dispatcher.addEventListener(EventName.CrossGuildWarClickTopXBtn, this.viewRoundXHandler);
            Dispatcher.addEventListener(EventName.CrossGuildWarRefleshLive, this.refleshLiveInfoReqHandler);
            Dispatcher.addEventListener(EventName.CrossGuildWarWatchGuildWar, this.watchGuildWarHandler);
            Dispatcher.addEventListener(EventName.Scene_Update, this.sceneUpdateHandler);
            return;
        }

        /* internal  */leaveWarToWaittingRoomReqHandler(arg1: DataEvent): void
        {
            var loc1=Language.getString(80573);
            if (cache.role.entityInfo.fightModel == EEntityFightMode._EEntityFightModeObseve) 
            {
                loc1 = Language.getString(90322);
            }
            Alert.show(loc1, null, Alert.OK | Alert.CANCEL, null, this.closeLeaveToWaittingRoom);
            return;
        }

        /* internal  */closeLeaveToWaittingRoom(arg1: int): void
        {
            if (arg1 != Alert.OK) 
            {
                return;
            }
            GameProxy.copy.crossGuildWarEnterCopy();
            return;
        }

        /* internal  */sceneUpdateHandler(arg1: DataEvent): void
        {
            if (!GameMapUtil.curMapState.isCrossGuildWar) 
            {
                if (this._infoPanel) 
                {
                    this._infoPanel.clear();
                }
                DisplayUtil.removeMe(this._infoPanel);
                if (this._isLastInCrossGuildWar) 
                {
                    this._isLastInCrossGuildWar = false;
                    Dispatcher.dispatchEvent(new DataEvent(EventName.TaskTrackShowOrHide, true));
                    Dispatcher.dispatchEvent(new DataEvent(EventName.ShowGameMainUI, true));
                    this.canNotUseItemData["addCanNotAttackMask"] = false;
                    Dispatcher.dispatchEvent(new DataEvent(EventName.ShortcutUsableUpdate, this.canNotUseItemData));
                }
                return;
            }
            this._isLastInCrossGuildWar = true;
            Dispatcher.dispatchEvent(new DataEvent(EventName.TaskTrackShowOrHide, false));
            Dispatcher.dispatchEvent(new DataEvent(EventName.ShowGameMainUI, false));
            this.canNotUseItemData["addCanNotAttackMask"] = true;
            Dispatcher.dispatchEvent(new DataEvent(EventName.ShortcutUsableUpdate, this.canNotUseItemData));
            if (GameMapUtil.curMapState.isCrossGuildWarWaittingRoom) 
            {
                if (this._infoPanel) 
                {
                    this._infoPanel.clear();
                }
                DisplayUtil.removeMe(this._infoPanel);
                if (!(this._signUpWin == null) && !this._signUpWin.isHide) 
                {
                    this._signUpWin.hide();
                }
                return;
            }
            if (this._module && !this._module.isHide) 
            {
                this._module.hide();
            }
            if (this._chooseGroupWin && !this._chooseGroupWin.isHide) 
            {
                this._chooseGroupWin.hide();
            }
            if (this._signUpWin && !this._signUpWin.isHide) 
            {
                this._signUpWin.hide();
            }
            if (this._infoPanel == null) 
            {
                this._infoPanel = new CrossGuildWarCopyInfoPanel();
            }
            this._infoPanel.updateData(cache.crossGuildWar.leftPlayerInfos);
            this._infoPanel.updateData2(cache.crossGuildWar.killPlayerInfos);
            this._infoPanel.updateEndTime(cache.crossGuildWar.getRoundEndLeftSeconds());
            this._infoPanel.show();
            return;
        }

        /* internal  */signUpStartHandler(arg1: MessageBlock): void
        {
            cache.crossGuildWar.isWarEnd = false;
            var loc1=arg1.messageBase as SGuildWarSingUpTime;
            cache.crossGuildWar.signUpInfo = loc1;
            cache.crossGuildWar.curStage = CrossGuildWarStage.SignUp;
            if (this._iconBtn == null) 
            {
                this._iconBtn = new CrossGuildWarBtn();
            }
            this._iconBtn.showEffect(true);
            this._iconBtn.show();
            return;
        }

        /* internal  */signUpInfoHandler(arg1: MessageBlock): void
        {
            var loc1=arg1.messageBase as SGuildWarSingUpInfo;
            cache.crossGuildWar.signUpPlayers = loc1;
            cache.crossGuildWar.isWarEnd = false;
            if (GuildwarSignListWindow.hasInstance()) 
            {
                GuildwarSignListWindow.instance.updateData(loc1);
            }
            if (!(this._signUpWin == null) && !this._signUpWin.isHide) 
            {
                this.showWin(CrossGuildWarController.ShowSignUpType);
            }
            return;
        }

        /* internal  */openHandler(arg1: MessageBlock): void
        {
            var loc1=arg1.messageBase as SGuildWarOpen;
            cache.crossGuildWar.isWarEnd = false;
            if (this._iconBtn == null) 
            {
                this._iconBtn = new CrossGuildWarBtn();
            }
            this._iconBtn.showEffect(true);
            this._iconBtn.show();
            return;
        }

        /* internal  */closeHandler(arg1: MessageBlock): void
        {
            cache.crossGuildWar.isWarEnd = true;
            if (this._iconBtn == null) 
            {
                return;
            }
            if (this._iconBtn != null) 
            {
                this._iconBtn.hide();
                this._iconBtn.dispose(true);
                this._iconBtn = null;
            }
            return;
        }

        /* internal  */chooseGroupTimeHandler(arg1: MessageBlock): void
        {
            if (!(this._signUpWin == null) && !this._signUpWin.isHide) 
            {
                this._signUpWin.hide();
            }
            this.chooseGroupHandler(arg1);
            this.showWin(CrossGuildWarController.ShowChooseGroupType);
            return;
        }

        /* internal  */chooseGroupHandler(arg1: MessageBlock): void
        {
            cache.crossGuildWar.isWarEnd = false;
            var loc1=arg1.messageBase as SCrossGuildWarChooseGroupInfo;
            cache.crossGuildWar.groupInfo = loc1;
            cache.crossGuildWar.curStage = CrossGuildWarStage.ChooseGroup;
            if (!(this._chooseGroupWin == null) && !this._chooseGroupWin.isHide) 
            {
                this.showWin(CrossGuildWarController.ShowChooseGroupType);
            }
            return;
        }

        /* internal  */viewRoundXHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data as CrossGuildWarChooseForTopBtnData;
            if (loc1 == null) 
            {
                return;
            }
            this._curViewingRoundIndex = loc1.index;
            if (loc1.isCurIndex) 
            {
                if (this._module != null) 
                {
                    this._module.showChooseForTopWin();
                }
                return;
            }
            this._isViewingHistory = true;
            GameProxy.copy.crossGuildWarGetMatchInfos(1, 100);
            return;
        }

        /* internal  */chooseEnemyTimeHandler(arg1: MessageBlock): void
        {
            this._chooseEnemyTimeBlock = arg1;
            LoaderHelp.addResCallBack(ResFileConst.CrossGuildWar, this.onGetResWhenChooseTime);
            return;
        }

        /* internal  */onGetResWhenChooseTime(): void
        {
            this._isResGetting = false;
            this._isResGot = true;
            this.showWin(CrossGuildWarController.ShowModuleType);
            this.chooseEnemyHandler(this._chooseEnemyTimeBlock);
            return;
        }

        /* internal  */chooseEnemyHandler(arg1: MessageBlock): void
        {
            var loc2=false;
            if (this._chooseGroupWin != null) 
            {
                this._chooseGroupWin.hide();
                this._chooseGroupWin.dispose(false);
                this._chooseGroupWin = null;
            }
            cache.crossGuildWar.isWarEnd = false;
            var loc1=arg1.messageBase as SCrossGuildWarChooseEnemyInfo;
            cache.crossGuildWar.enemyInfo = loc1;
            if (loc1 != null) 
            {
                loc2 = false;
                if (cache.crossGuildWar.curStage != loc1.ring) 
                {
                    loc2 = true;
                }
                cache.crossGuildWar.curStage = loc1.ring;
                if (loc2 && !(this._module == null)) 
                {
                    this._module.setTabSelected(CrossGuildWarModuleTabIndex.chooseEnemy);
                }
            }
            CallLater.addCallBack(this.chooseEnemyChangeNextFrameHandler);
            return;
        }

        /* internal  */chooseEnemyChangeNextFrameHandler(): void
        {
            if (!cache.crossGuildWar.isOurGuildInChooseList()) 
            {
                return;
            }
            this.moduleTabChangedHandler(null);
            return;
        }

        /* internal  */roundBeginHandler(arg1: MessageBlock): void
        {
            var loc1=arg1.messageBase as SCrossGuildWarBeginWar;
            if (loc1 == null) 
            {
                return;
            }
            cache.crossGuildWar.curRoundData = loc1;
            cache.crossGuildWar.curStage = loc1.ring + 10;
            if (loc1.status == ECrossGuildWarFightStatus._ECrossGuildWarFail) 
            {
                this.showWin(CrossGuildWarController.ShowModuleType);
                this.moduleTabChangedHandler(null);
            }
            return;
        }

        /* internal  */roundEndHandler(arg1: MessageBlock): void
        {
            var loc1=arg1.messageBase as SCrossGuildWarEndWar;
            if (loc1 == null) 
            {
                return;
            }
            if (loc1.ring == CrossGuildWarStage.FightForTop1) 
            {
                cache.crossGuildWar.curStage = CrossGuildWarStage.End;
            }
            return;
        }

        /* internal  */liveInfoHandler(arg1: MessageBlock): void
        {
            var loc1=arg1.messageBase as SCrossGuildWarMatchInfos;
            if (loc1 == null) 
            {
                return;
            }
            var loc2=-1;
            if (this._isViewingHistory) 
            {
                this._isViewingHistory = false;
                cache.crossGuildWar.historyLiveInfos = loc1;
                loc2 = this._curViewingRoundIndex + 1;
                if (this._module == null) 
                {
                    return;
                }
                this._module.updateLiveData(cache.crossGuildWar.getHistoryLiveDatas(loc2), loc2 + 10);
                this._module.chooseForTopWin.updateEnemyGuild(cache.crossGuildWar.getHistoryEnemyGuildData(), ECrossGuildWarFightStatus._ECrossGuildWarFail);
                this._module.chooseForTopWin.updateSelfGuild(cache.crossGuildWar.getSelfGuildData(), ECrossGuildWarFightStatus._ECrossGuildWarSuccess);
                this._module.chooseForTopWin.updateStatusTips(cache.crossGuildWar.getHistoryStatusData());
                this._module.updateTopBtns(cache.crossGuildWar.getChooseForTopBtnDatas(this._curViewingRoundIndex));
            }
            else 
            {
                cache.crossGuildWar.liveInfos = loc1;
                if (this._module == null) 
                {
                    return;
                }
                this._module.chooseForTopWin.updateStatusTips(cache.crossGuildWar.getFingtStatusParams());
                loc2 = CrossGuildWarUtil.getCurRoundIndex(cache.crossGuildWar.curStage) + 1;
                this._module.updateLiveData(cache.crossGuildWar.getLiveDatas(loc2), cache.crossGuildWar.curStage);
            }
            return;
        }

        /* internal  */rankInfoHandler(arg1: MessageBlock): void
        {
            var loc1=arg1.messageBase as SCrossGuildWarFinalRanks;
            cache.crossGuildWar.rankInfos = loc1;
            this._module.showRankWin(loc1.pageNum, new DataProvider(cache.crossGuildWar.getRankInfos()), loc1.guildNum, cache.crossGuildWar.getOurGuildRankPlace());
            return;
        }

        /* internal  */leftPlayerInfoHandler(arg1: MessageBlock): void
        {
            var loc1=arg1.messageBase as SCrossGuildWarLeftNum;
            cache.crossGuildWar.leftPlayerInfos = loc1;
            if (this._infoPanel == null) 
            {
                return;
            }
            this._infoPanel.updateData(loc1);
            this._infoPanel.updateEndTime(cache.crossGuildWar.getRoundEndLeftSeconds());
            return;
        }

        /* internal  */copyInfoUpdateHandler(arg1: MessageBlock): void
        {
            var loc1=arg1.messageBase as SCrossGuildWarScore;
            cache.crossGuildWar.killPlayerInfos = loc1;
            if (this._infoPanel != null) 
            {
                this._infoPanel.updateData2(loc1);
                this._infoPanel.updateEndTime(cache.crossGuildWar.getRoundEndLeftSeconds());
            }
            return;
        }

        /* internal  */groupEndHandler(arg1: MessageBlock): void
        {
            this.showWin(CrossGuildWarController.ShowModuleType, this.showLastRankCallBack);
            return;
        }

        /* internal  */showLastRankCallBack(): void
        {
            if (this._module == null) 
            {
                return;
            }
            this._module.setTabSelected(CrossGuildWarModuleTabIndex.scheduleRank);
            this.moduleTabChangedHandler(null);
            return;
        }

        /* internal  */refleshLiveInfoReqHandler(arg1: DataEvent): void
        {
            if (this._curViewingRoundIndex != CrossGuildWarUtil.getCurRoundIndex(cache.crossGuildWar.curStage)) 
            {
                return;
            }
            GameProxy.copy.crossGuildWarGetMatchInfos(1, 100);
            return;
        }

        /* internal  */watchGuildWarHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data as SCrossGuildWarMatchInfo;
            GameProxy.copy.crossGuildWarEnterCopy(loc1.guildWarId);
            return;
        }

        /* internal  */openModuleReqHandler(arg1: DataEvent): void
        {
            if (cache.crossGuildWar.curStage == CrossGuildWarStage.ChooseGroup) 
            {
                this.showWin(CrossGuildWarController.ShowChooseGroupType);
                return;
            }
            if (cache.crossGuildWar.curStage == CrossGuildWarStage.SignUp || !GameMapUtil.curMapState.isCrossGuildWar) 
            {
                this.showWin(CrossGuildWarController.ShowSignUpType);
                return;
            }
            if (GameMapUtil.curMapState.isCrossGuildWar) 
            {
                if (!cache.crossGuildWar.isOurGuildInChooseList()) 
                {
                    MsgManager.showRollTipsMsg(Language.getString(80592));
                    return;
                }
                this.showWin(CrossGuildWarController.ShowModuleType);
            }
            return;
        }

        /* internal  */moduleAddToStageHandler(arg1: Object /* flash.events.Event */): void
        {
            this.stageChangedHandler(null);
            var loc1=cache.crossGuildWar.curStage;
            switch (loc1) 
            {
                case CrossGuildWarStage.ChooseForTop16: case CrossGuildWarStage.ChooseForTop1: case CrossGuildWarStage.ChooseForTop2: case CrossGuildWarStage.ChooseForTop4: case CrossGuildWarStage.ChooseForTop8:
                {
                    this.moduleTabChangedHandler(null);
                    break;
                }
                default:
                {
                    this.moduleTabChangedHandler(null);
                    break;
                }
            }
            return;
        }

        /* internal  */showWin(arg1: int, arg2: Function=null): void
        {
            if (this._isResGetting) 
            {
                return;
            }
            this._showWinCallBack = arg2;
            if (this._isResGot) 
            {
                this.showWinAction(arg1);
            }
            else 
            {
                this._isResGetting = true;
                LoaderHelp.addResCallBack(ResFileConst.CrossGuildWar, this.onGetRes);
                this._curShowType = arg1;
            }
            return;
        }

        /* internal  */onGetRes(): void
        {
            this._isResGetting = false;
            this._isResGot = true;
            this.showWinAction(this._curShowType);
            return;
        }

        /* internal  */showWinAction(arg1: int): void
        {
            var loc1=arg1;
            switch (loc1) 
            {
                case CrossGuildWarController.ShowSignUpType:
                {
                    this.showSignUpWin(this._showWinCallBack);
                    break;
                }
                case CrossGuildWarController.ShowChooseGroupType:
                {
                    this.showChooseGroupWin(this._showWinCallBack);
                    break;
                }
                case CrossGuildWarController.ShowModuleType:
                {
                    this.showModule(this._showWinCallBack);
                    break;
                }
            }
            return;
        }

        /* internal  */showModule(arg1: Function=null): void
        {
            if (this._module == null) 
            {
                this._module = new CrossGuildWarModule();
                this._module.addEventListener(flash.events.Event.ADDED_TO_STAGE, this.moduleAddToStageHandler);
                this._module.addEventListener(flash.events.Event.REMOVED_FROM_STAGE, this.moduleRemovedHandler);
            }
            this._module.show();
            if (arg1 != null) 
            {
                arg1.call();
            }
            return;
        }

        /* internal  */showSignUpWin(arg1: Function=null): void
        {
            if (this._signUpWin == null) 
            {
                this._signUpWin = new CrossGuildWarSignUpWin();
            }
            var loc1=0;
            if (cache.guild.myGuildInfo != null) 
            {
                loc1 = cache.guild.myGuildInfo.contribution;
            }
            this._signUpWin.updateCurHave(loc1);
            this._signUpWin.updateCurSignUpCount(cache.crossGuildWar.getOurGuildSignUpNum());
            this._signUpWin.updateLeftTime(cache.crossGuildWar.getSignUpLeftSeconds());
            this._signUpWin.show();
            if (cache.crossGuildWar.hasSignUp(cache.role.entityInfo.name)) 
            {
                this._signUpWin.signUpEnabled = false;
            }
            if (arg1 != null) 
            {
                arg1.call();
            }
            return;
        }

        /* internal  */showChooseGroupWin(arg1: Function): void
        {
            if (this._chooseGroupWin == null) 
            {
                this._chooseGroupWin = new CrossGuildWarChooseGroupWin();
            }
            this._chooseGroupWin.updateSelectLeftTime(cache.crossGuildWar.getChooseGroupLeftSeconds());
            this._chooseGroupWin.updateData(cache.crossGuildWar.getGroupData());
            this._chooseGroupWin.show();
            if (arg1 != null) 
            {
                arg1.call();
            }
            return;
        }

        /* internal  */moduleRemovedHandler(arg1: Object /* flash.events.Event */): void
        {
            if (!cache.crossGuildWar.isWarEnd) 
            {
                return;
            }
            if (this._module == null) 
            {
                return;
            }
            this._module.dispose(true);
            this._module = null;
            return;
        }

        /* internal  */signUpReqHandler(arg1: DataEvent): void
        {
            GameProxy.copy.crossGuildWarSignUp();
            return;
        }

        /* internal  */enterCopyReqHandler(arg1: DataEvent): void
        {
            if (GameMapUtil.curMapState.isCrossGuildWar) 
            {
                return;
            }
            GameProxy.copy.crossGuildWarEnterCopy();
            return;
        }

        /* internal  */showSignUpListHandler(arg1: DataEvent): void
        {
            if (!GuildwarSignListWindow.hasInstance() || GuildwarSignListWindow.instance.isHide) 
            {
                GuildwarSignListWindow.instance.layer = this._signUpWin;
                GuildwarSignListWindow.instance.show();
                GuildwarSignListWindow.instance.x = 840;
                GuildwarSignListWindow.instance.y = 0;
                if (cache.crossGuildWar.signUpPlayers != null) 
                {
                    GuildwarSignListWindow.instance.updateData(cache.crossGuildWar.signUpPlayers);
                }
            }
            else 
            {
                GuildwarSignListWindow.instance.hide();
            }
            return;
        }

        /* internal  */chooseGroupReqHandler(arg1: DataEvent): void
        {
            if (cache.guild.myGuildInfo == null) 
            {
                MsgManager.showRollTipsMsg(Language.getString(41802));
                return;
            }
            if (!(cache.guild.myGuildInfo.position == EGuildPosition._EGuildLeader) && !(cache.guild.myGuildInfo.position == EGuildPosition._EGuildDeputyLeader)) 
            {
                MsgManager.showRollTipsMsg(Language.getString(80562));
                return;
            }
            var loc1=cache.crossGuildWar.getGuildGroupId(cache.guild.myGuildInfo.guildId);
            if (loc1 > 0) 
            {
                MsgManager.showRollTipsMsg(Language.getStringByParam(80561, loc1));
                return;
            }
            this._chooseGroupData = arg1.data as SCrossGuildWarChooseGroup;
            if (this._chooseGroupData == null) 
            {
                return;
            }
            Alert.show(Language.getStringByParam(80571, this._chooseGroupData.groupId), null, Alert.OK | Alert.CANCEL, null, this.closeChooseGroupConfirm);
            return;
        }

        /* internal  */closeChooseGroupConfirm(arg1: int): void
        {
            if (!(arg1 == Alert.OK) || this._chooseGroupData == null) 
            {
                return;
            }
            GameProxy.copy.crossGuildWarChooseGroup(this._chooseGroupData.groupId);
            return;
        }

        public static /* const */ShowSignUpType: int=0;

        public static /* const */ShowChooseGroupType: int=1;

        public static /* const */ShowModuleType: int=2;

        private /* var */_module: CrossGuildWarModule;

        private /* var */_moduleViewControlCenter: CrossGuildWarModuleShowControlCenter;

        private /* var */_iconBtn: CrossGuildWarBtn;

        private /* var */_enterTipsControl: CrossGuildWarEnterWaittingRoomTips;

        private /* var */_infoPanel: CrossGuildWarCopyInfoPanel;

        private /* var */_signUpWin: CrossGuildWarSignUpWin;

        private /* var */_chooseGroupWin: CrossGuildWarChooseGroupWin;

        private /* var */_isLastInCrossGuildWar: Boolean=false;

        private /* var */canNotUseItemData: Object;

        private /* var */_chooseEnemyTimeBlock: MessageBlock;

        private /* var */_isResGot: Boolean=false;

        private /* var */_isResGetting: Boolean=false;

        private /* var */_chooseGroupData: SCrossGuildWarChooseGroup;

        private /* var */_curViewingRoundIndex: int=-1;

        private /* var */_isViewingHistory: Boolean=false;

        private /* var */_showWinCallBack: Function;

        private /* var */_curShowType: int=2;

        private /* var */_chooseForTopXData: CrossGuildWarChooseForTopData;
    }
